From 77bb01ece2b083754509cf443254b4b95783e15d Mon Sep 17 00:00:00 2001 From: Sondre Lefsaker Date: Fri, 1 May 2015 23:47:07 +0200 Subject: [PATCH] Add a new field to CompileOptions and BuildConfig: `target_rustc_args` - The new field is a list with arguments to compile the target with. - There should only be one target that gets compiled with these arguments --- src/bin/bench.rs | 1 + src/bin/build.rs | 1 + src/bin/doc.rs | 1 + src/bin/run.rs | 1 + src/bin/rustc.rs | 1 + src/bin/test.rs | 1 + src/cargo/ops/cargo_compile.rs | 7 ++++++- src/cargo/ops/cargo_package.rs | 1 + src/cargo/ops/cargo_rustc/mod.rs | 1 + 9 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/bin/bench.rs b/src/bin/bench.rs index ec5e92722..dd5bb5ee5 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -75,6 +75,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_test, &options.flag_example, &options.flag_bench), + target_rustc_args: None, }, }; diff --git a/src/bin/build.rs b/src/bin/build.rs index cb925510a..3af175ec1 100644 --- a/src/bin/build.rs +++ b/src/bin/build.rs @@ -76,6 +76,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_test, &options.flag_example, &options.flag_bench), + target_rustc_args: None, }; ops::compile(&root, &opts).map(|_| None).map_err(|err| { diff --git a/src/bin/doc.rs b/src/bin/doc.rs index ed05f9f55..bd1127e2f 100644 --- a/src/bin/doc.rs +++ b/src/bin/doc.rs @@ -62,6 +62,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { mode: ops::CompileMode::Doc { deps: !options.flag_no_deps, }, + target_rustc_args: None, }, }; diff --git a/src/bin/run.rs b/src/bin/run.rs index 9ff8728fa..c34c36be1 100644 --- a/src/bin/run.rs +++ b/src/bin/run.rs @@ -72,6 +72,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { bins: &bins, examples: &examples, } }, + target_rustc_args: None, }; let err = try!(ops::run(&root, diff --git a/src/bin/rustc.rs b/src/bin/rustc.rs index c7de721db..f3d6fdf9d 100644 --- a/src/bin/rustc.rs +++ b/src/bin/rustc.rs @@ -85,6 +85,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_test, &options.flag_example, &options.flag_bench), + target_rustc_args: None, }; ops::compile(&root, &opts).map(|_| None).map_err(|err| { diff --git a/src/bin/test.rs b/src/bin/test.rs index f7a7ba555..6199f917b 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -79,6 +79,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { &options.flag_test, &options.flag_example, &options.flag_bench), + target_rustc_args: None, }, }; diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 6231dcb1d..38a71dc76 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -58,6 +58,9 @@ pub struct CompileOptions<'a, 'b: 'a> { pub release: bool, /// Mode for this compile. pub mode: CompileMode, + /// The specified target will be compiled with all the available arguments, + /// note that this only accounts for the *final* invocation of rustc + pub target_rustc_args: Option<&'a [String]>, } #[derive(Clone, Copy, PartialEq)] @@ -102,7 +105,8 @@ pub fn compile_pkg(package: &Package, options: &CompileOptions) -> CargoResult { let CompileOptions { config, jobs, target, spec, features, no_default_features, release, mode, - ref filter, ref exec_engine } = *options; + ref filter, ref exec_engine, + ref target_rustc_args } = *options; let target = target.map(|s| s.to_string()); let features = features.iter().flat_map(|s| { @@ -168,6 +172,7 @@ pub fn compile_pkg(package: &Package, options: &CompileOptions) let mut build_config = try!(scrape_build_config(config, jobs, target)); build_config.exec_engine = exec_engine.clone(); build_config.release = release; + build_config.target_rustc_args = target_rustc_args.map(|a| a.to_vec()); if let CompileMode::Doc { deps } = mode { build_config.doc_all = deps; } diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 0392580a8..892512d54 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -189,6 +189,7 @@ fn run_verify(config: &Config, pkg: &Package, tar: &Path) exec_engine: None, release: false, mode: ops::CompileMode::Build, + target_rustc_args: None, })); Ok(()) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index e1535bb8f..4cb5f5b9b 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -43,6 +43,7 @@ pub struct BuildConfig { pub exec_engine: Option>>, pub release: bool, pub doc_all: bool, + pub target_rustc_args: Option>, } #[derive(Clone, Default)] -- 2.30.2